package com.lc.my_springframework.beans.factory.config;

import com.lc.my_springframework.beans.ConfigurablePropertyValues;
import com.lc.my_springframework.beans.MutablePropertyValues;
import com.lc.my_springframework.beans.PropertyValues;
import lombok.*;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class BeanDefinition {
    private ConfigurablePropertyValues propertyValues;
    private String beanName;
    private Class clazz;
    private boolean singleton;

    public BeanDefinition(String beanName, Class clazz, boolean singleton) {
        this.beanName = beanName;
        this.clazz = clazz;
        this.singleton = singleton;
    }

    public PropertyValues getPropertyValues() {
        ConfigurablePropertyValues pvs = this.propertyValues;
        if (pvs == null) {
            pvs = new MutablePropertyValues();
            this.propertyValues = pvs;
        }
        return pvs;
    }
}
